home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / v cisle / sadanastroju / delicious_bookmarks-2.0.64-fx.xpi / chrome / deliciousBookmarks.jar / content / ybookmarksStatusOverlay.js < prev    next >
Encoding:
Text File  |  2008-06-19  |  38.5 KB  |  1,108 lines

  1. var CC = Components.classes;
  2. var CI = Components.interfaces;
  3.  
  4. /**
  5.  *  Class manages all the icons on status bar
  6.  */
  7. function statusBarIcon(id, labelId) {
  8.     this._icon = null;
  9.     this._iconLabel = null;
  10.     this._init(id, labelId);
  11. }
  12.  
  13. statusBarIcon.prototype = {
  14.     _init: function (id, labelId) {
  15.         try {
  16.             this._icon = document.getElementById(id);
  17.             if(labelId)    this._iconLabel = document.getElementById(labelId);
  18.         } catch (e) {
  19.             yDebug.print("ybookmarkStatusOverlay.js::statusBarIcon::_init()=>Exception: "+e,YB_LOG_MESSAGE);
  20.         }
  21.     },
  22.     setImage: function (url) {
  23.         this._icon.setAttribute("src",url)
  24.     },
  25.     showIcon: function () {
  26.         this._icon.hidden = false;
  27.         this._icon.collapsed = false;
  28.     },
  29.     hideIcon: function () {
  30.         this._icon.hidden = true;
  31.         this._icon.collapsed = true;
  32.     },
  33.     setLabel: function (val) {
  34.         this._iconLabel.value = val;
  35.     },
  36.     showLabel: function () {
  37.         this._iconLabel.style.display = "";
  38.     },
  39.     hideLabel: function () {
  40.         this._iconLabel.style.display = "none";
  41.     }
  42. }
  43.  
  44. /**
  45.  * Class manages all the popup windows on status bar
  46.  */
  47. function popWindow(id) {
  48.     this.id = id;
  49.     this.posX = null;
  50.     this.posY = null;
  51.     this.textnode = null;
  52.     this.isOpen = false;
  53.     this.popWind = document.getElementById(this.id);
  54.     this.enabled = true;
  55. }
  56.  
  57. popWindow.prototype = {
  58.     prepareContent: function (id, content) {
  59.         try {
  60.              this.textnode = document.createTextNode(content);
  61.              document.getElementById(id).replaceChild(this.textnode, document.getElementById(id).firstChild);
  62.         } catch (e) {
  63.             yDebug.print("ybookmarkStatusOverlay.js::popWindow::prepareContent()=>Exception: "+e,YB_LOG_MESSAGE);
  64.         }
  65.     },
  66.     
  67.     perpareElement: function (id, attrName, attrValue) {
  68.         try {
  69.             document.getElementById(id).setAttribute(attrName, attrValue);
  70.             document.getElementById(id).setAttribute(attrName, attrValue);
  71.         } catch (e) {
  72.             yDebug.print("ybookmarkStatusOverlay.js::popWindow::prepareElement()=>Exception: "+e,YB_LOG_MESSAGE);
  73.         }
  74.     },
  75.     
  76.     /**
  77.      * Prepare pupup position based on parameter passed broad positioning
  78.      * Calculate screen resolution and window screen position and show popup accordingly
  79.      */
  80.     preparePosition: function(broaderPosition){
  81.         var maxWidth = screen.width - parseInt(this.popWind.firstChild.style.minWidth);
  82.         var maxHeight = screen.height - parseInt(this.popWind.firstChild.style.minHeight);
  83.         
  84.         var winX = window.screenX;
  85.         var winY = window.screenY;
  86.         
  87.         var winWidth = window.innerWidth;
  88.         var winHeight = window.innerHeight;
  89.         
  90.         var posWidth = winX + winWidth - parseInt(this.popWind.firstChild.style.minWidth);
  91.         var posHeight = winY + winHeight - parseInt(this.popWind.firstChild.style.minHeight);
  92.         
  93.         if(!broaderPosition) broaderPosition = 'bottomright';
  94.         
  95.         switch(broaderPosition){
  96.             case 'bottomright':
  97.                 //calculate position to put popup at bottom right part of window
  98.  
  99.                 if(maxWidth <= posWidth) this.posX = maxWidth;
  100.                 else if(maxWidth > posWidth) this.posX = posWidth;
  101.  
  102.                 if(maxHeight <= posHeight) this.posY = maxHeight;
  103.                 else if(maxHeight > posHeight) this.posY = posHeight;
  104.                 
  105.                 this.posX -= 10;
  106.                 this.posY -= 10;
  107.                 
  108.                 yDebug.print("ybookmarkStatusOverlay.js::popWindow::preparePosition()=>: maxWidth-"+maxWidth+" posWidth-"+posWidth+" X-"+this.posX+" Y-"+this.posY,YB_LOG_MESSAGE);
  109.                 
  110.                 if(this.posX >= 0 && this.posY >= 0) return true;
  111.                 else return false;
  112.         }
  113.     },
  114.     
  115.     
  116.     show: function (objRef) {
  117.         
  118.         if(!this.enabled) return;
  119.         
  120.         /**
  121.          * Do nothing if its already open
  122.          */
  123.         if(this.isOpen) {
  124.             this.hide();
  125.             this.isOpen = false;
  126.         }
  127.         
  128.         try {
  129.             /**
  130.              * Show popup window
  131.              */
  132.             //this.popWind.position = "end_after";
  133.             //this.popWind.position = "before_end";
  134.             //this.popWind.showPopup(objRef,this.posX,this.posY,'popup','bottomright','topright');
  135.             
  136.             //if(!objRef.boxObject  || objRef.boxObject.screenX < 0 || objRef.boxObject.screenY < 0) {
  137.                 //not visible
  138.                 //alert("alert icon is not visible");
  139.                 //return;                
  140.             //}
  141.             //alert(objRef.boxObject.screenX + ":" + objRef.boxObject.screenY);            
  142.             //this.popWind.showPopup(objRef,objRef.boxObject.screenX,objRef.boxObject.screenY,'popup','bottomright','topright');
  143.             if(this.posX && this.posY) {
  144.                 this.popWind.showPopup(objRef,this.posX,this.posY,'popup','bottomright','topright');
  145.             }
  146.             else {
  147.                 this.popWind.showPopup(objRef,-1,-1,'popup','bottomright','topright');
  148.             }
  149.             this.isOpen = true;
  150.         } catch (e) {
  151.             yDebug.print("ybookmarkStatusOverlay.js::popWindow::show()=>Exception: "+e,YB_LOG_MESSAGE);
  152.         }
  153.     },
  154.     
  155.     hide: function () {
  156.         if(!this.popWind) return;
  157.         
  158.         try {
  159.             this.popWind.hidePopup();
  160.             this.isOpen = false;
  161.         } catch (e) {
  162.             yDebug.print("ybookmarkStatusOverlay.js::popWindow::hide()=>Exception: "+e,YB_LOG_MESSAGE);
  163.         }
  164.     },
  165.     
  166.     enable: function () {
  167.         this.enabled = true;
  168.     },
  169.     
  170.     disable: function () {
  171.         this.enabled = false;    
  172.     }
  173. }
  174.  
  175. //Changes tag icon color for bookmarked urls 
  176. function changeTagIcon(url) 
  177. {
  178.     if(!url) {
  179.         return;
  180.     }
  181.     var storeService = Components.classes["@mozilla.org/ybookmarks-store-service;1"].
  182.                                     getService(Components.interfaces.nsIYBookmarksStoreService);
  183.     var bookmarkResource = storeService.isBookmarked( url );
  184.     yDebug.print ( "Existing entry for " + url );
  185.     var toolbarTagIcon = document.getElementById("del-button-tagPage");
  186.     var styleClassName = "toolbar-tag-effect";
  187.     var navbar = document.getElementById("nav-bar");
  188.     if(navbar && (navbar.getAttribute("iconsize") == "small")) {
  189.         styleClassName = "toolbar-tag-effect-small";
  190.     }
  191.     if(toolbarTagIcon && bookmarkResource) {         
  192.        toolbarTagIcon.setAttribute("class", styleClassName);
  193.        toolbarTagIcon.setAttribute("del", "true");
  194.     } else {                
  195.        toolbarTagIcon.setAttribute("class", styleClassName);
  196.        toolbarTagIcon.setAttribute("del", "false");
  197.     }
  198. }
  199.  
  200. /**
  201.  * Listner class for adress bar changes to provide data for tagometer
  202.  */
  203. var urlBarListener = {
  204.      
  205.   QueryInterface: function(aIID)
  206.   {
  207.    if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
  208.        aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
  209.        aIID.equals(Components.interfaces.nsISupports))
  210.      return this;
  211.    throw Components.results.NS_NOINTERFACE;
  212.   },
  213.  
  214.   onLocationChange: function(aProgress, aRequest, aURI)
  215.   {
  216.     /**
  217.      * Before adding new values update old contents to blank
  218.      */        
  219.     try { 
  220.         var url =  aProgress.DOMWindow.location.href;
  221.         statusBar.getTagometerData(url);        
  222.         changeTagIcon(url);
  223.     } catch(e) {
  224.         //This is happening on startup at times.
  225.         yDebug.print("Exception in ybookmarkStatusOverlay.js::urlBarListener::onLocationChange:" +  e, YB_LOG_MESSAGE);
  226.     }    
  227.   },
  228.  
  229.   onStateChange: function() {},
  230.   onProgressChange: function() {},
  231.   onStatusChange: function() {},
  232.   onSecurityChange: function() {},
  233.   onLinkIconAvailable: function() {}
  234. };
  235.  
  236. /**
  237.  * Status Bar class handles all the things on status bar
  238.  */
  239. var statusBar = {
  240.     delIcon: null,
  241.     alertIcon: null,
  242.     networkIcon: null,
  243.     inboxIcon: null,
  244.     tagoIcon: null,
  245.     delIconOff: null,
  246.     networkOff: null,
  247.     inboxActive: null,
  248.     tagoActive: null,
  249.     prefService: null,
  250.     extBranch: null,
  251.     links4u: 0,
  252.     tagoCount: null,
  253.     alertWindow: null,
  254.     tagoWindow: null,
  255.     strbundle: null,
  256.     alertMessage: null,
  257.     os: null,
  258.     hash: null,
  259.     networkTimer: null,
  260.     alertTimer: null,
  261.     //alertInfoPopupTimer: null,
  262.     //oldAlertTimerInterval: null,
  263.     alertUpdatetime: null,
  264.     alertLastUpdateTime: null,
  265.     tagReq: null,
  266.     prefsUpdateTimer: null,
  267.     tagoRequestFailCount: 0,
  268.     canShowAlertWindow: true,
  269.  
  270.     init: function () {
  271.         this.delIcon = new statusBarIcon("delicious-status-bar-delicious-image");
  272.         this.alertIcon = new statusBarIcon("delicious-status-bar-alert-image");        
  273.         this.networkIcon = document.getElementById("delicious-status-bar-network-image");
  274.         
  275.         this.inboxIcon = new statusBarIcon("delicious-status-bar-inbox-image", "delicious-status-bar-inbox-count");
  276.         this.inboxIcon.hideIcon();
  277.         
  278.         this.tagoIcon = new statusBarIcon("delicious-status-bar-vitality-image", "delicious-status-bar-vitality-count");
  279.         
  280.         this.alertWindow = new popWindow('delicious-status-bar-popup');
  281.         this.tagoWindow = new popWindow("tagometer-popup");
  282.         
  283.         this.strbundle = document.getElementById("ybookmarks-status-bar-strings");
  284.         
  285.         try { 
  286.             this.register();
  287.         } catch(e) { 
  288.             yDebug.print("ybookmarkStatusOverlay.js::statusBar::init()=>Exception: "+e,YB_LOG_MESSAGE);
  289.         }
  290.     },
  291.  
  292.     register: function () {
  293.         try {
  294.             this.prefService = Components.classes["@mozilla.org/preferences-service;1"]
  295.                                      .getService(Components.interfaces.nsIPrefService);
  296.             
  297.             this.extBranch = this.prefService.getBranch("extensions.ybookmarks@yahoo");
  298.             this.extBranch.QueryInterface(Components.interfaces.nsIPrefBranch2); 
  299.             this.extBranch.addObserver("", this, false);     
  300.             
  301.             this.os = Components.classes["@mozilla.org/observer-service;1"]
  302.                                      .getService(Components.interfaces.nsIObserverService);
  303.             this.os.addObserver ( this, "ybookmark.updateLinks4u", false );
  304.             this.os.addObserver ( this, "ybookmark.userChanged", false );
  305.             
  306.             //Listen for webpage loads
  307.             gBrowser.addProgressListener(urlBarListener, Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
  308.             
  309.         } catch (e) {
  310.             yDebug.print("ybookmarkStatusOverlay.js::statusBar::register()=>Exception: "+e,YB_LOG_MESSAGE);
  311.         }
  312.     },
  313.     
  314.     unregister: function () {
  315.         if(this.extBranch) {
  316.             try {
  317.                 this.extBranch.removeObserver("", this);
  318.             } catch (e) {
  319.                 yDebug.print("ybookmarkStatusOverlay.js::statusBar::unregister()=>Exception: "+e,YB_LOG_MESSAGE);
  320.             }
  321.         }
  322.         
  323.         if(this.os) {
  324.             try {
  325.                 this.os.removeObserver(this, "ybookmark.updateLinks4u");
  326.                 this.os.removeObserver(this, "ybookmark.userChanged");                
  327.             } catch (e) {
  328.                 yDebug.print("ybookmarkStatusOverlay.js::statusBar::unregister()=>Exception: "+e,YB_LOG_MESSAGE);
  329.             }
  330.         }
  331.         
  332.         //remove progress listner
  333.         gBrowser.removeProgressListener(urlBarListener);
  334.     },
  335.     
  336.     getUpdatedPrefs: function () {
  337.         try {
  338.             this.networkOff = this.prefService.getBoolPref("extensions.ybookmarks@yahoo.statusbaricons.disable_networkreminder");
  339.             this.inboxActive = this.prefService.getBoolPref("extensions.ybookmarks@yahoo.statusbaricons.include_linksforyou");
  340.             //this.tagoActive = this.prefService.getBoolPref("extensions.ybookmarks@yahoo.statusbaricons.include_tagometer");
  341.             this.delIconOff = this.prefService.getBoolPref("extensions.ybookmarks@yahoo.statusbaricons.disable_delicious_icon");
  342.             this.tagoActive = false;
  343.             
  344.             this.updateTagoCount();
  345.             this.setTagometerMessage("");
  346.  
  347.             if(this.networkOff && !this.inboxActive && this.delIconOff) {
  348.                 document.getElementById("delicious-status-bar-panel").hidden = true;
  349.             } else {
  350.                 document.getElementById("delicious-status-bar-panel").hidden = false;
  351.             }
  352.         } catch (e) {
  353.             yDebug.print("ybookmarkStatusOverlay.js::statusBar::getUpdatedPrefs()=>Exception: "+e,YB_LOG_MESSAGE);
  354.         }
  355.     },
  356.     
  357.     loadIcons: function () {
  358.         try {
  359.             this.delIcon.setImage("chrome://ybookmarks/skin/deliciousIconSmall.gif");
  360.             if(this.delIconOff) {
  361.                 this.delIcon.hideIcon();
  362.             } else {
  363.                 this.delIcon.showIcon();
  364.             }
  365.             
  366.             this.alertIcon.setImage("chrome://ybookmarks/skin/alertTransparent.gif");
  367.  
  368.             //hide the alert icon initially
  369.             //this.alertIcon.hideIcon();
  370.             this.inboxIcon.setImage((this.links4u > 0) ? "chrome://ybookmarks/skin/inboxActive.gif" : "chrome://ybookmarks/skin/inboxInactive.gif");
  371.             this.tagoIcon.setImage(this.tagoActive?"chrome://ybookmarks/skin/tagometerActive.gif":"chrome://ybookmarks/skin/tagometerInactive.gif");
  372.             
  373.             
  374.                     
  375.             if(this.inboxActive) {
  376.                 this.inboxIcon.showIcon();
  377.                 if(this.links4u > 0) this.inboxIcon.showLabel();
  378.                 
  379.                 this.inboxIcon._iconLabel.setAttribute("tooltiptext", this.strbundle.getFormattedString("extensions.ybookmarks.statusbar.links4uIcon.tooltip", [ this.links4u ]));
  380.                 this.inboxIcon._icon.setAttribute("tooltiptext", this.strbundle.getFormattedString("extensions.ybookmarks.statusbar.links4uIcon.tooltip", [ this.links4u ]));
  381.                 this.inboxIcon._icon.setAttribute("onclick", "ybookmarksUtils.openLinkToNewTab('"+deliciousService.getLinks4uUrl()+"'); statusBar.updateLinks4u();");
  382.                 this.inboxIcon._iconLabel.setAttribute("onclick", "ybookmarksUtils.openLinkToNewTab('"+deliciousService.getLinks4uUrl()+"'); statusBar.updateLinks4u();");
  383.             }
  384.             else {
  385.                 this.inboxIcon.hideIcon();
  386.                 this.inboxIcon.hideLabel();
  387.  
  388.                 this.inboxIcon._iconLabel.removeAttribute("tooltiptext");
  389.                 this.inboxIcon._icon.removeAttribute("tooltiptext");
  390.             }
  391.             
  392.             if(this.tagoActive && this.tagoCount > 0) {
  393.                 this.tagoIcon.showLabel();
  394.                 this.tagoIcon._iconLabel.setAttribute("tooltiptext", this.strbundle.getFormattedString("extensions.ybookmarks.statusbar.tagometerIcon.tooltip", [ this.tagoCount ]));
  395.                 this.tagoIcon._icon.setAttribute("tooltiptext", this.strbundle.getFormattedString("extensions.ybookmarks.statusbar.tagometerIcon.tooltip", [ this.tagoCount ]));
  396.             }
  397.             else {
  398.                 this.tagoIcon._iconLabel.removeAttribute("tooltiptext");
  399.                 this.tagoIcon._icon.removeAttribute("tooltiptext");
  400.                 this.tagoIcon.hideLabel();
  401.             }            
  402.         } catch (e) {
  403.             yDebug.print("ybookmarkStatusOverlay.js::statusBar::loadIcons()=>Exception: "+e,YB_LOG_MESSAGE);
  404.         }
  405.     },
  406.     
  407.     reloadNetwork: function () {
  408.         if(statusBar.networkOff) {
  409.             statusBar.networkIcon.hidden = true;
  410.             statusBar.clearNetworkTimer();                
  411.         } else {
  412.             statusBar.networkIcon.hidden = false;
  413.             statusBar.setNetworkTimer();
  414.         }
  415.     },
  416.     
  417.     observe: function (aSubject, aTopic, aData) {
  418.         switch(aTopic) {
  419.             case "nsPref:changed":
  420.                 try {
  421.                     this.getUpdatedPrefs();
  422.                     this.loadIcons();
  423.                     this.reloadNetwork();
  424.                     if(this.tagoActive) {
  425.                         statusBar.getTagometerData(gBrowser.contentWindow.location.href);
  426.                     }
  427.                 } catch (e) {
  428.                     yDebug.print("ybookmarkStatusOverlay.js::statusBar::observe()=>Exception: "+e,YB_LOG_MESSAGE);
  429.                 }
  430.             break;
  431.             
  432.             case "ybookmark.updateLinks4u":
  433.                 this.updateLinks4u(aData);
  434.             break;
  435.             
  436.             case "ybookmark.userChanged":                
  437.                 if(aData == "loggedin") {
  438.                     statusBar.setNetworkTimer();
  439.                     //statusBar.setAlertTimer();
  440.                 } else if(aData == "loggedout" || aData == "cookie_expired" || aData == "silentlogout") {
  441.                     statusBar.clearNetworkTimer();
  442.                     //statusBar.clearAlertTimer();
  443.                 }
  444.             break;
  445.         }
  446.     },
  447.     
  448.     updateLinks4u: function (links) {
  449.         
  450.         if(!this.inboxActive) {
  451.             this.inboxIcon.hideLabel();
  452.             return;
  453.         }
  454.         
  455.         this.links4u = (!links)?0:links;
  456.         
  457.         if(this.links4u <= 0) {
  458.             this.inboxIcon.hideLabel();
  459.         }
  460.         else {
  461.             this.inboxIcon.setLabel(this.links4u);
  462.             this.inboxIcon.showLabel();
  463.         }
  464.         
  465.         this.loadIcons();
  466.     },
  467.     
  468.     updateTagoCount: function (count) {
  469.         if(!this.tagoActive) {
  470.             this.tagoIcon.hideLabel();
  471.             this.tagoIcon.hideIcon();
  472.             return;
  473.         }
  474.  
  475.         this.tagoCount = (!count) ? 0 : count;
  476.  
  477.         if(this.tagoCount > 0) {            
  478.             var title = document.getElementById("tagometer-popuptitle-label");
  479.             if(this.tagoCount == 1) {
  480.                 title.value = this.strbundle.getString("extensions.ybookmarks.statusbar.tagometer.single.title");      
  481.             } else {
  482.                 title.value = this.strbundle.getString("extensions.ybookmarks.statusbar.tagometer.multi.title");
  483.             }
  484.  
  485.             this.tagoIcon.setLabel(this.tagoCount);
  486.             this.tagoIcon.showLabel();            
  487.             this.tagoIcon.showIcon();
  488.         }
  489.         else {
  490.             this.tagoIcon.hideIcon();
  491.             this.tagoIcon.hideLabel();
  492.         }
  493.  
  494.         this.loadIcons();
  495.     },
  496.     
  497.     getTagometerData: function(url) {
  498.         // Do nothing if tagometer is disabled
  499.         if(!this.tagoActive) {
  500.             return;
  501.         }
  502.  
  503.         if(this.tagReq) {
  504.             this.tagReq.abortRequest();
  505.         }
  506.         
  507.         this.updateTagoCount();
  508.         this.setTagometerMessage("");
  509.     
  510.           if(url != "about:blank") {
  511.               var msg = "";          
  512.               var hash = hex_md5(url);
  513.             this.hash = hash;
  514.  
  515. //            this.hash = encodeURIComponent(url);
  516.             
  517.               yDebug.print("ybookmarkStatusOverlay.js::statusBar::getTagometerData()=> hash: "+this.hash,YB_LOG_MESSAGE);
  518.               yDebug.print("ybookmarkStatusOverlay.js::statusBar::getTagometerData()=> calling: "+deliciousService.getTagometerUrl()+this.hash,YB_LOG_MESSAGE);
  519.               
  520.               var callBack = {
  521.                 onload : function(event) {
  522.  
  523.                     yDebug.print("ybookmarkStatusOverlay.js::statusBar::getTagometerData()=> Called Callback. Response"+event.target.responseText,YB_LOG_MESSAGE);
  524.  
  525.                     if(event.target.responseText) {
  526.                         var response = eval(event.target.responseText);
  527.                         if(typeof(response) == "object") {
  528.                             statusBar.updateTagoCount(response[0]["total_posts"]);
  529.                             statusBar.setTagometerMessage(response[0]["top_tags"]);
  530.                             
  531.                             //reset failed requests counter
  532.                             statusBar.tagoRequestFailCount = 0;
  533.                         }
  534.                     }                                    
  535.  
  536.                 },
  537.                 onprogress: function(event) {
  538.                     yDebug.print("ybookmarkStatusOverlay.js::statusBar::getTagometerData()=> status: "+event.target.status,YB_LOG_MESSAGE);
  539.                 },
  540.                 onerror : function(event) {
  541.                     yDebug.print("ybookmarkStatusOverlay.js::statusBar::getTagometerData()=> Error: Error in fetching tagometer data. Resending the request.",YB_LOG_MESSAGE);
  542.                     
  543.                     //resend only if less than 2 requests have already sent
  544.                     if(statusBar.tagoRequestFailCount < 2) {
  545.                         //resend the fetch request if error occurs
  546.                         statusBar.getTagometerData(gBrowser.contentWindow.location.href);
  547.                         statusBar.tagoRequestFailCount++;
  548.                     }
  549.                 }
  550.             };          
  551.               this.tagReq = new yHttpGet(deliciousService.getTagometerUrl()+this.hash, callBack);
  552.           }
  553.     },
  554.     
  555.     showAlertWindow: function (objRef) {
  556.         try {
  557. /*                if(statusBar.alertLink) {
  558.                     document.getElementById("delicious-status-bar-popupbottom").style.display = '';
  559.                     document.getElementById("delicious-status-bar-goto-link").setAttribute("onclick", "ybookmarksUtils.openLinkToNewTab('"+statusBar.alertLink+"'); statusBar.hideAlertWindow();");
  560.                     document.getElementById("delicious-status-bar-goto-image").setAttribute("onclick", "ybookmarksUtils.openLinkToNewTab('"+statusBar.alertLink+"'); statusBar.hideAlertWindow();");
  561.                 }
  562.                 else {
  563.                     document.getElementById("delicious-status-bar-popupbottom").style.display = 'none';
  564.                 }
  565. */                
  566.                 /**
  567.                  * Show alert window only if browser window is focused
  568.                  */
  569.                 if(!statusBar.canShowAlertWindow) return;
  570.  
  571.                  //this.alertWindow.prepareContent("delicious-status-bar-popupcontent-label", this.alertMessage);
  572.                  document.getElementById("delicious-status-bar-popupcontent-label").innerHTML = this.alertMessage;
  573.                 
  574.                  statusBar.alertWindow.preparePosition('bottomright');
  575.                  
  576.                  this.alertWindow.show(objRef);
  577.         } catch (e) {
  578.             yDebug.print("ybookmarkStatusOverlay.js::statusBar::showAlertWindow()=>Exception: "+e,YB_LOG_MESSAGE);
  579.         }
  580.      },
  581.      
  582.      hideAlertWindow: function () {
  583.         this.alertWindow.hide();
  584.         //this.alertIcon.hideIcon();        
  585.      },
  586.      
  587.      showTagoWindow: function (objRef) {
  588.         if(this.tagoCount) {
  589.              try {
  590.                  this.tagoWindow.perpareElement("tagometer-popuptitle-count", "value", this.tagoCount);
  591.                  this.tagoWindow.perpareElement("tagometer-goto-link", "onclick", "ybookmarksUtils.openLinkToNewTab('"+deliciousService.getUrl("url/"+this.hash)+"'); statusBar.hideTagoWindow();");
  592.                  this.tagoWindow.perpareElement("tagometer-goto-image", "onclick", "ybookmarksUtils.openLinkToNewTab('"+deliciousService.getUrl("url/"+this.hash)+"'); statusBar.hideTagoWindow();");
  593.                  this.tagoWindow.prepareContent("tagometer-popupcontent-label", this.tagometerMessage);
  594.                  
  595.                  this.tagoWindow.posX = -1;
  596.                  this.tagoWindow.posY = -1;
  597.                  this.tagoWindow.show(objRef);
  598.              } catch (e) {
  599.                  yDebug.print("ybookmarkStatusOverlay.js::statusBar::showTagoWindow()=>Exception: "+e,YB_LOG_MESSAGE);
  600.              }
  601.         }
  602.      },
  603.      
  604.      hideTagoWindow: function () {
  605.         this.tagoWindow.hide();
  606.      },
  607.     
  608.     setAlertMessage: function (msg) {
  609.         this.alertMessage = msg;
  610.     },
  611.     
  612.     setTagometerMessage: function (topTags) {
  613.         if(typeof(topTags) == "object") {
  614.             var i = 1;
  615.             
  616.             /**
  617.              * If toptags are blank dont show popup window
  618.              */
  619.             if(topTags == "") {
  620.                 this.tagoWindow.disable();
  621.             }
  622.             else {
  623.                 this.tagoWindow.enable();
  624.             }
  625.             
  626.             for(var c in topTags) {
  627.                 if(i > 5) break;
  628.                 
  629.                 //skip tag imported
  630.                 if(c == "imported") {
  631.                     i++;
  632.                     continue;
  633.                 }
  634.                 
  635.                 document.getElementById("tagometer-toptag"+i).value = c;
  636.                 document.getElementById("tagometer-toptag"+i).style.display = "";
  637.                 document.getElementById("tagometer-toptag"+i).setAttribute("onclick","ybookmarksUtils.openLinkToNewTab(deliciousService.getUrl('"+"popular/"+c+"')); statusBar.hideTagoWindow();");
  638.                 i++;    
  639.                 document.getElementById("tagometer-toptags-head").style.display = "";
  640.             }
  641.         }
  642.         else {
  643.             document.getElementById("tagometer-toptags-head").style.display = "none";
  644.             for(i=0; i < 5; i++) {
  645.                 document.getElementById("tagometer-toptag"+(i+1)).style.display = "none";
  646.             }
  647.             //set tago label empty
  648.             this.tagoIcon.setLabel("");
  649.         }
  650.     },
  651.     
  652.     //for alpha
  653.     _getTextContents : function(node) {
  654.         var result = "";
  655.         var doc = node.ownerDocument;
  656.         doc.QueryInterface(CI.nsIDOMDocumentTraversal);
  657.         var treeWalker = doc.createTreeWalker(node,
  658.           CI.nsIDOMNodeFilter.SHOW_TEXT | CI.nsIDOMNodeFilter.SHOW_CDATA_SECTION,
  659.           null, true);
  660.         var curNode = treeWalker.currentNode;
  661.         while (curNode) {
  662.           try {
  663.             curNode.QueryInterface(CI.nsIDOMCharacterData);
  664.             result += curNode.data;
  665.           } catch (e) {}
  666.           curNode = treeWalker.nextNode();
  667.         }
  668.         return result;  
  669.     },
  670.     //for alpha
  671.     getTimeFromDOM: function(posts) {
  672.         var dateString = null;
  673.         try {
  674.             var rssDOM = posts.queryElementAt(0, CI.nsIDOMDocument);    
  675.             var nodeList = rssDOM.getElementsByTagName("item");     
  676.             if(nodeList && nodeList.length) {
  677.                 var node = nodeList[0];
  678.                 var childNode = node.firstChild;
  679.                 while(childNode) {
  680.                     if (childNode.nodeType == CI.nsIDOMNode.ELEMENT_NODE) {
  681.                         childNode.QueryInterface(CI.nsIDOMElement);
  682.                         var childName = childNode.nodeName;
  683.                         if (childName == "dc:date") {
  684.                           dateString = statusBar._getTextContents(childNode);
  685.                           //yDebug.print("dateString is : " + dateString, YB_LOG_MESSAGE);                    
  686.                           return dateString;
  687.                         }                   
  688.                     }
  689.                     childNode = childNode.nextSibling;
  690.                 }
  691.             }
  692.         } catch(e) {
  693.             yDebug.print("exception in getTimefromDOM");
  694.         }
  695.         return dateString;
  696.     },
  697.     
  698.     activateNetworkIcon : function() {
  699.         statusBar.networkIcon.setAttribute("status", "active");
  700.         statusBar.networkIcon.setAttribute("tooltiptext", statusBar.strbundle.getString("extensions.ybookmarks.statusbar.network.active.tooltip"));                        
  701.     },
  702.     
  703.     inactivateNetworkIcon : function() {
  704.         statusBar.networkIcon.setAttribute("status", "inactive");
  705.         statusBar.networkIcon.setAttribute("tooltiptext", statusBar.strbundle.getString("extensions.ybookmarks.statusbar.network.inactive.tooltip"));                        
  706.     },
  707.     
  708.     
  709.     handleNetwork : function () {
  710.         if(deliciousService.getUserName()) {    
  711.             var cb = {
  712.               onload : function(posts) {                  
  713.                   if(!posts) {                      
  714.                       return;       
  715.                   }        
  716.                                     
  717.                   /*                        
  718.                   //yDebug.print("valid post,length:"+ posts.length);
  719.                   var rssDOM = posts.queryElementAt(0, Components.interfaces.nsIDOMDocument);
  720.                   var timeArray = ybookmarksUtils.evaluateXPath(rssDOM,"//item[1]/pubDate");
  721.                  var time = null;
  722.                 if(timeArray && timeArray[0]) {
  723.                     time = timeArray[0].textContent;
  724.                 }      
  725.                 */ 
  726.                 var time = statusBar.getTimeFromDOM(posts);
  727.                 //Do this only if user is logged in
  728.                   if(time && deliciousService.getUserName()) {
  729.                     var storeService = Components.classes["@mozilla.org/ybookmarks-store-service;1"].
  730.                                         getService(Components.interfaces.nsIYBookmarksStoreService);
  731.                     var lastTime = storeService.getFeedLastUpdateTime(deliciousService.getNetworkFeedUrl());
  732.                     //Show the icon,There is some nw activity
  733.                     if(!lastTime) {
  734.                         statusBar.activateNetworkIcon();
  735.                     } else if(time != lastTime) {
  736.                         statusBar.activateNetworkIcon();
  737.                     }            
  738.                   }                  
  739.               },
  740.               onerror : function(event) {
  741.                   yDebug.print("ybookmarksStatusOverlay.js:handleNetwork:Onerror",YB_LOG_MESSAGE);                  
  742.               }
  743.             }
  744.             var socialStore = Components.classes["@yahoo.com/socialstore/delicious;1"].
  745.                                     getService(Components.interfaces.nsISocialStore);            
  746.             socialStore.getFeedData(deliciousService.getNetworkFeedUrl(), cb);
  747.         }
  748.     },
  749.  
  750.     onNetworkClick: function () {
  751.         //Make icon inactive
  752.         statusBar.inactivateNetworkIcon();        
  753.         //Open the network page.        
  754.         ybookmarksUtils.openLinkToNewTab(deliciousService.getNetworkUrl());
  755.         
  756.         var cb = {
  757.           onload : function(posts) {              
  758.               if(!posts) {                      
  759.                   return;       
  760.             }         
  761.             /*         
  762.             var rssDOM = posts.queryElementAt(0, Components.interfaces.nsIDOMDocument);            
  763.             var timeArray = ybookmarksUtils.evaluateXPath(rssDOM,"//item[1]/pubDate");
  764.             var time = null;
  765.             if(timeArray && timeArray[0]) {
  766.                 time = timeArray[0].textContent;
  767.             }
  768.             */
  769.             var time = statusBar.getTimeFromDOM(posts);
  770.               if(time && deliciousService.getUserName()) {
  771.                 var storeService = Components.classes["@mozilla.org/ybookmarks-store-service;1"].
  772.                                     getService(Components.interfaces.nsIYBookmarksStoreService); 
  773.                 storeService.setFeedLastUpdateTime(deliciousService.getNetworkFeedUrl(), time);
  774.               }              
  775.           },
  776.           onerror : function(event) {
  777.               yDebug.print("ybookmarksStatusOverlay.js:OnNetworkClick:Onerror",YB_LOG_MESSAGE);
  778.           }
  779.         }    
  780.         //Do this only if user is logged in
  781.         if(deliciousService.getUserName()) {    
  782.             //Get the latest timestamp
  783.             var socialStore = Components.classes["@yahoo.com/socialstore/delicious;1"].
  784.                                     getService(Components.interfaces.nsISocialStore); 
  785.             socialStore.getFeedData(deliciousService.getNetworkFeedUrl(), cb);
  786.         }
  787.     },
  788.  
  789.     setNetworkTimer : function () {
  790.         //User must be logged in.
  791.         if(!deliciousService.getUserName()) {
  792.             return;
  793.         }        
  794.         
  795.         //default to 10 minutes
  796.         yDebug.print("ybookmarksStatusOverlay.js::setNetworkTimer",YB_LOG_MESSAGE);
  797.         var interval = 60*10; //seconds => 10 minutes
  798.         try {
  799.             interval = this.prefService.getIntPref("extensions.ybookmarks@yahoo.statusbaricons.networkpoll.interval");
  800.         } catch(e) {}        
  801.         statusBar.clearNetworkTimer();
  802.         if (!statusBar.networkTimer) {          
  803.           statusBar.networkTimer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer);
  804.         } else {        
  805.           statusBar.networkTimer.cancel();
  806.         }        
  807.         statusBar.networkTimer.initWithCallback(this, interval * 1000,
  808.                                                  Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
  809.     },
  810.     
  811.     clearNetworkTimer : function () {
  812.         if(statusBar.networkTimer) {
  813.             statusBar.networkTimer.cancel();
  814.             statusBar.networkTimer = null;
  815.         }        
  816.     },
  817.     
  818.     /*
  819.     setAlertInfoPopupTimer : function () {
  820.      
  821.            yDebug.print("ybookmarksStatusOverlay.js::setAlertInfoPopup Timer",YB_LOG_MESSAGE);
  822.         var interval = 5*1000;// 5 seconds
  823.         if (!statusBar.alertInfoPopupTimer) {          
  824.           statusBar.alertInfoPopupTimer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer);
  825.         } else {        
  826.           statusBar.alertInfoPopupTimer.cancel();
  827.         }        
  828.  
  829.         statusBar.alertInfoPopupTimer.initWithCallback(this, interval,
  830.                                                  Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);                                                 
  831.     },
  832.     
  833.     clearAlertInfoPopupTimer : function () {
  834.         if(statusBar.alertInfoPopupTimer) {
  835.             statusBar.alertInfoPopupTimer.cancel();
  836.         }        
  837.     },
  838.     */
  839.     
  840.     setAlertTimer : function (delay) {
  841.         //default to 10 minutes
  842.            yDebug.print("ybookmarksStatusOverlay.js::setAlertTimer",YB_LOG_MESSAGE);
  843.         var interval = 60 * 10; //seconds => 10 minutes
  844.         try {
  845.             interval = this.prefService.getIntPref("extensions.ybookmarks@yahoo.statusbaricons.alertpoll.interval");
  846.         } catch(e) {}        
  847.         if (!statusBar.alertTimer) {          
  848.           statusBar.alertTimer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer);
  849.         } else {        
  850.           statusBar.alertTimer.cancel();
  851.         }        
  852.         
  853.         /*
  854.         statusBar.oldAlertTimerInterval = interval;        
  855.         if(delay) interval = delay;
  856.         //else interval *= 60;
  857.         */        
  858.         
  859.         yDebug.print("ybookmarksStatusOverlay.js:handleAlert:Timer set to "+interval+" secs",YB_LOG_MESSAGE);
  860.                              
  861.         statusBar.alertTimer.initWithCallback(this, interval * 1000,
  862.                                                  Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);                                                 
  863.     },
  864.     
  865.     clearAlertTimer : function () {
  866.         if(statusBar.alertTimer) {
  867.             statusBar.alertTimer.cancel();
  868.             statusBar.alertTimer = null;
  869.         }        
  870.     },
  871.     
  872.     handleAlert : function () {
  873.         if(deliciousService.getUserName()) {
  874.             var cb = {
  875.               onload : function(posts) {
  876.                   if(!posts) {
  877.                       return;       
  878.                   }                  
  879.                 var rssDOM = posts.queryElementAt(0, Components.interfaces.nsIDOMDocument);
  880.                 var timeArray = ybookmarksUtils.evaluateXPath(rssDOM,"//item[1]/pubDate");                                  
  881.                          
  882.                   var time = null;       
  883.                   if(timeArray && timeArray[0]) {     
  884.                       time = timeArray[0].textContent;    
  885.                   }                
  886.                 if(!time) {
  887.                       statusBar.alertIcon.hideIcon();
  888.                       return;
  889.                   } else {
  890.                       alertUpdatetime = time;
  891.                   }
  892.                 /*
  893.                 if(statusBar.alertWindow.preparePosition('bottomright') == false){
  894.                      //Put 10 seconds interval since popup is to be shown
  895.                      statusBar.clearAlertTimer();
  896.                      statusBar.setAlertTimer(10);
  897.                      return;
  898.                      }        
  899.                 */
  900.                 //Do this only if use is logged in
  901.                   if(time && deliciousService.getUserName()) {
  902.                       
  903.                       try {
  904.                           
  905.                     var storeService = Components.classes["@mozilla.org/ybookmarks-store-service;1"].
  906.                                         getService(Components.interfaces.nsIYBookmarksStoreService);
  907.                     alertLastUpdateTime = storeService.getFeedLastUpdateTime(deliciousService.getAlertFeedUrl());
  908.                     var titleArray = ybookmarksUtils.evaluateXPath(rssDOM,"//item[1]/title");
  909.                     var linkArray = ybookmarksUtils.evaluateXPath(rssDOM,"//item[1]/link");
  910.                     var categoryArray = ybookmarksUtils.evaluateXPath(rssDOM,"//item[1]/category");
  911.  
  912.                     var title = titleArray[0].textContent;
  913.                     var category = categoryArray[0].textContent;
  914.                     
  915.                       } catch(e) {
  916.                           statusBar.alertIcon.hideIcon();
  917.                           return;    
  918.                       }
  919.                       
  920.                       /**
  921.                        * Check if title is not empty
  922.                        */ 
  923.                       if(title) {
  924.                           /**
  925.                            * Check if title contains at least one anchor tag
  926.                            */
  927.                           if(title.search(/href=/i) > -1) {
  928.                               /**
  929.                                * Parse title for anchors and add styles to them and add functionality to them
  930.                                */
  931.                               title = ybookmarksUtils.parseTextForAnchors(title);
  932.                           //    alert(title);
  933.                           }
  934.                           
  935.                           statusBar.setAlertMessage(title);
  936.                         //statusBar.setAlertMessage(title+'and <a href="http://www.yahoo.com" onclick="ybookmarksUtils.openLinkToNewTab('+"'http://www.yahoo.com/'"+')">Yahoo!</a>');
  937.                       }
  938.                       else {
  939.                           statusBar.alertIcon.hideIcon();
  940.                           return;    
  941.                       }
  942.                       
  943.                     
  944.                     if(time && alertLastUpdateTime && time==alertLastUpdateTime) {
  945.                         statusBar.alertIcon.showIcon();
  946.                     } else if(!alertLastUpdateTime || time!=alertLastUpdateTime){
  947.                         statusBar.alertIcon.showIcon();                        
  948.                            if (category == "warn"){
  949.                             if (ybookmarksUtils.getTopWindow() == window) {
  950.                                 statusBar.showAlertWindow(document.getElementById("delicious-status-bar-alert-image"));
  951.                             }
  952.                             //Put old interval since popup is already shown if interval is 10 seconds
  953.                             /*
  954.                             if(statusBar.alertTimer.delay == 10000){
  955.                                  statusBar.alertTimer.initWithCallback(this, statusBar.oldAlertTimerInterval, Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
  956.                             }*/
  957.                         } else if (category == "info"){                                       
  958.                             if (ybookmarksUtils.getTopWindow() == window) {
  959.                                 statusBar.showAlertWindow(document.getElementById("delicious-status-bar-alert-image"));
  960.                                 window.setTimeout(function() {statusBar.hideAlertWindow();}, 5000);
  961.                             }
  962.                             
  963.                             //yDebug.print("ybookmarksStatusOverlay.js:handleAlert: delay "+statusBar.alertTimer.delay,YB_LOG_MESSAGE);                            
  964.                             //Put old interval since popup is already shown if interval is 10 seconds
  965.                             /*
  966.                             if(statusBar.alertTimer.delay == 10000){
  967.                                 statusBar.clearAlertTimer();
  968.                                  statusBar.setAlertTimer(statusBar.oldAlertTimerInterval);
  969.                             }*/
  970.                             //start a timer that will close the alert window in 5 seconds
  971.                             //statusBar.setAlertInfoPopupTimer();                            
  972.                         }
  973.                         //storeService.setFeedLastUpdateTime(deliciousService.getAlertFeedUrl(), time);
  974.                       }
  975.                       
  976.                   }
  977.               },
  978.               onerror : function(event) {
  979.                   yDebug.print("ybookmarksStatusOverlay.js:handleAlert:Onerror",YB_LOG_MESSAGE);                  
  980.               }
  981.             }
  982.             var socialStore = Components.classes["@yahoo.com/socialstore/delicious;1"].
  983.                                     getService(Components.interfaces.nsISocialStore);            
  984.             socialStore.getFeedData(deliciousService.getAlertFeedUrl(), cb);
  985.         }
  986.     },
  987.     
  988.     alertPopupPresented : function() {    
  989.         if(alertUpdatetime != alertLastUpdateTime) {
  990.             var storeService = Components.classes["@mozilla.org/ybookmarks-store-service;1"].
  991.                                             getService(Components.interfaces.nsIYBookmarksStoreService);
  992.             storeService.setFeedLastUpdateTime(deliciousService.getAlertFeedUrl(), alertUpdatetime);    
  993.         }        
  994.     },
  995.     
  996.     canShowAlert: function () {
  997.         statusBar.canShowAlertWindow = true;    
  998.     },
  999.     
  1000.     cantShowAlert: function () {
  1001.         statusBar.canShowAlertWindow = false;
  1002.     },
  1003.     
  1004.     notify : function (aTimer) {
  1005.         
  1006.         if (aTimer == statusBar.networkTimer){
  1007.             yDebug.print("ybookmarksStatusOverlay.js:notify=> Network Timer notified.",YB_LOG_MESSAGE);
  1008.             statusBar.handleNetwork();
  1009.         }else if (aTimer == statusBar.alertTimer){
  1010.             yDebug.print("ybookmarksStatusOverlay.js:notify=> Alert Timer notified.",YB_LOG_MESSAGE);
  1011.             statusBar.handleAlert();
  1012.         }else if (aTimer == statusBar.prefsUpdateTimer) {
  1013.             statusBar.getTagometerData(gBrowser.contentWindow.location.href);
  1014.         }
  1015.     },
  1016.     
  1017.     loadStatusBar : function () {
  1018.         
  1019.         //:::Classic or FullMode:::        
  1020.         if(ybookmarksUtils.getExtensionMode() == YB_EXTENSION_MODE_CLASSIC)  {
  1021.             //Toolbar removal
  1022.             var element = document.getElementById("navigator-toolbox");
  1023.             if(element.hasChildNodes()){
  1024.                 for (var i = 0; i < element.childNodes.length; i++) {
  1025.                   if(element.childNodes[i].id == "ybToolbar") {
  1026.                       element.removeChild(element.childNodes[i]);
  1027.                       break;
  1028.                   }
  1029.                 }
  1030.             }
  1031.             //Hide sidebar button for classic mode.
  1032.             var sidebarButton = document.getElementById("del-button-delicious");
  1033.             if(sidebarButton) {                
  1034.                    sidebarButton.hidden = true;
  1035.             }            
  1036.             /*
  1037.             var sidebar = document.getElementById("sidebar-box");
  1038.             // close sidebar.
  1039.             if (!sidebar.hidden) {
  1040.                 toggleSidebar('viewYBookmarksSidebar', false);
  1041.             }
  1042.             */             
  1043.             return false;
  1044.         } else {            
  1045.             var showList = [ "delicious-status-bar-panel", //show status bar
  1046.                              //"del-button-delicious", //show sidebar button
  1047.                              "yb-viewSidebarMenuItem" //show sidebar menu
  1048.                            ];
  1049.                            
  1050.             function showElem(element) {                
  1051.                 var elem = document.getElementById(element);
  1052.                 if(elem) {                    
  1053.                     elem.hidden = false;
  1054.                 }
  1055.             }                          
  1056.             showList.forEach(showElem);
  1057.         }
  1058.         
  1059.         try {
  1060.             yDebug.print("ybookmarkStatusOverlay.js::loadStatusBar()=>Invoked ",YB_LOG_MESSAGE);
  1061.         
  1062.             statusBar.init();
  1063.             yDebug.print("ybookmarkStatusOverlay.js::loadStatusBar()::statusBar.init()=>Initialized ",YB_LOG_MESSAGE);
  1064.         
  1065.             statusBar.getUpdatedPrefs();
  1066.             yDebug.print("ybookmarkStatusOverlay.js::loadStatusBar()::statusBar.getUpdatedPrefs()=>Updated Pref Fetched ",YB_LOG_MESSAGE);
  1067.         
  1068.             statusBar.loadIcons();
  1069.             statusBar.reloadNetwork();
  1070.             //no alert in alpha
  1071.             statusBar.alertIcon.hideIcon();
  1072.             
  1073.             yDebug.print("ybookmarkStatusOverlay.js::loadStatusBar()::statusBar.loadIcons()=>Icons Loaded ",YB_LOG_MESSAGE);            
  1074.             /* No alert in alpha
  1075.             statusBar.setAlertTimer();    
  1076.             
  1077.             window.addEventListener("focus", statusBar.canShowAlert, true);
  1078.             window.addEventListener("blur", statusBar.cantShowAlert, true);
  1079.             */ 
  1080.         } catch (e) {
  1081.                 yDebug.print("ybookmarkStatusOverlay.js::loadStatusBar()=>Exception: "+e,YB_LOG_MESSAGE);
  1082.         }    
  1083.     },
  1084.  
  1085.     statusBarCleanup : function () {
  1086.         try {
  1087.             statusBar.unregister();
  1088.             statusBar.clearNetworkTimer();
  1089.             statusBar.clearAlertTimer();
  1090.  
  1091.             window.removeEventListener("focus", statusBar.canShowAlert, true);
  1092.             window.removeEventListener("blur", statusBar.cantShowAlert, true);
  1093.         } catch (e) {
  1094.             yDebug.print("ybookmarkStatusOverlay.js::statusBar::cleanup()=>Exception: "+e,YB_LOG_MESSAGE);
  1095.         }
  1096.     }    
  1097. };
  1098.  
  1099. function deleteStatusbarHeap() 
  1100. {
  1101.     statusBar.statusBarCleanup();
  1102.     statusBar = null;
  1103.  
  1104. //statusBar.
  1105. window.addEventListener("load", statusBar.loadStatusBar, false);
  1106. window.addEventListener("unload", deleteStatusbarHeap, false);
  1107.